home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7309 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: chronicle.mti.sgi.com!news
  2. From: austern@isolde.mti.sgi.com (Matt Austern)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: pow(-1,1.1) = DOMAIN error
  5. Date: 22 Feb 1996 17:30:39 GMT
  6. Organization: SGI
  7. Message-ID: <AUSTERN.96Feb22093039@isolde.mti.sgi.com>
  8. References: <Christian.Straka.15.0010E3C9@uni-konstanz.de>
  9. Reply-To: austern@mti.sgi.com
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. In-reply-to: Christian.Straka@uni-konstanz.de's message of Thu, 22 Feb 1996 16:53:16
  12.  
  13. In article <Christian.Straka.15.0010E3C9@uni-konstanz.de> Christian.Straka@uni-konstanz.de (Christian Straka) writes:
  14.  
  15. > The pow() and powl() function in <math.h> doesn't work properly. The following 
  16. > example causes a DOMAIN error exception (see defs in math.h):
  17. >              pow(-1,1.1);
  18. > Has anyone an idea to fix this problem?
  19.  
  20. Two choices.  First choice: use a version of pow() that knows about
  21. complex numbers.  If you #include complex.h, then pow(complex(-1), 1.1)
  22. ought to do the trick.
  23.  
  24. Second choice: don't do it.  If you're looking for a real answer, then
  25. you've done your math wrong.  There's no way that pow(-1,1.1) can give
  26. you a real number, whether you're using C, C++, Eiffel, or Fortran:
  27. mathematically, (-1) ^ 1.1 is not real.
  28. -- 
  29. Matt Austern
  30. SGI: MTI Compilers Group
  31. austern@isolde.mti.sgi.com
  32.